package com.whmnx.main.ui.model;

import android.content.Intent;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.tencent.qcloud.ugckit.UGCKitConstants;
import com.whmnx.base.bean.VideoBean;
import com.whmnx.main.ui.videorecord.TCVodPlayerActivity;

import java.io.Serializable;

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

/**
 * author : huang
 * date   : 2020/9/28 0028 19:21
 * version: 1.0
 */
public class WorkItemViewModel2 extends ItemViewModel {

    public ObservableField<String> tvNum = new ObservableField<>("");

    public String imgUrl;
    LikeModel viewModel;
    int position ;
    VideoBean videoBean;
    public WorkItemViewModel2(@NonNull LikeModel viewModel, VideoBean videoBean, int i) {
        super(viewModel);
        this.viewModel = viewModel;
        this.videoBean = videoBean;
        this.position = i;
        if (TextUtils.isEmpty(videoBean.getWork_Image())){
            this.imgUrl = videoBean.getWork_Vidoe();
        }else {
            this.imgUrl = videoBean.getWork_Image();
        }

        tvNum.set(videoBean.playNum);
    }

    //播豆
    public BindingCommand OnClickCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            Intent intent = new Intent(viewModel.mFragment.getActivity(), TCVodPlayerActivity.class);
            intent.putExtra(UGCKitConstants.PLAY_URL, videoBean.getWork_Vidoe());
            intent.putExtra(UGCKitConstants.PUSHER_ID, "");
          //  intent.putExtra(UGCKitConstants.PUSHER_NAME, item.nickname == null ? item.userid : item.nickname);
            intent.putExtra(UGCKitConstants.PUSHER_AVATAR, videoBean.getWork_Image());
            intent.putExtra(UGCKitConstants.COVER_PIC, videoBean.getWork_Image());
            intent.putExtra(UGCKitConstants.FILE_ID, "");
            intent.putExtra(UGCKitConstants.TCLIVE_INFO_LIST, (Serializable) viewModel.mTCLiveInfoList);
            intent.putExtra(UGCKitConstants.TIMESTAMP, "");
            intent.putExtra(UGCKitConstants.TCLIVE_INFO_POSITION, position);
            viewModel.mFragment.getActivity().startActivityForResult(intent, 100);
        }
    });
}
